package com.qr.write;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileOutputStream;

/**
 * 大量数据写入07版本
 *      写入无限制，但是比较慢，非常消耗内存
 */
public class BigDateWrite07 {
    public static void main(String[] args) throws Exception{

        String path = "E:\\workspace\\GitRepository\\java-framework\\poi\\poi-use\\src\\main\\resources";

        Workbook sheets = new XSSFWorkbook();
        Sheet sheet = sheets.createSheet();

        for (int i = 0; i < 65537; i++) {
            Row row = sheet.createRow(i);
            for (int j = 0; j < 10; j++) {
                Cell cell = row.createCell(j);
                cell.setCellValue(j);
            }
        }

        //生成表
        FileOutputStream fileOutputStream = new FileOutputStream(path + "大文件07.xlsx");
        sheets.write(fileOutputStream);

        fileOutputStream.close();
    }
}
